

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>克隆 Ceph 源码库 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="构建 Ceph" href="../build-ceph/" />
    <link rel="prev" title="下载 Ceph 源码包" href="../get-tarballs/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">安装 Ceph</a></li>
          <li class="breadcrumb-item"><a href="../index_manual/">安装（手动）</a></li>
      <li class="breadcrumb-item active">克隆 Ceph 源码库</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/install/clone-source.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">安装 Ceph</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#id1">建议的方法</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id2">其他方法</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="../index_manual/">安装（手动）</a><ul class="current">
<li class="toctree-l4 current"><a class="reference internal" href="../index_manual/#id2">获取软件</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id3">安装软件</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id4">手动部署一套集群</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id5">升级软件</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#windows">Windows</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="ceph">
<h1>克隆 Ceph 源码库<a class="headerlink" href="#ceph" title="Permalink to this heading"></a></h1>
<p>你可以去<a class="reference external" href="https://github.com/ceph/ceph">位于 github 的 Ceph 源码库</a>克隆某个 Ceph 分支，先选择一个分支（默认是 <code class="docutils literal notranslate"><span class="pre">main</span></code> ），然后点击 <strong>Download ZIP</strong> 按钮。</p>
<p>要克隆整个 git 源码库，你得先<a class="reference internal" href="#install-git"><span class="std std-ref">安装</span></a>并配置 <code class="docutils literal notranslate"><span class="pre">git</span></code> 。</p>
<section id="git">
<span id="install-git"></span><h2>安装 Git<a class="headerlink" href="#git" title="Permalink to this heading"></a></h2>
<p>在 Debian/Ubuntu 上执行下列命令安装 <code class="docutils literal notranslate"><span class="pre">git</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "$ ";
}
</style><span class="prompt1">sudo<span class="w"> </span>apt-get<span class="w"> </span>install<span class="w"> </span>git</span>
</pre></div></div><p>在 CentOS/RHEL 上执行下列命令安装 <code class="docutils literal notranslate"><span class="pre">git</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">sudo<span class="w"> </span>yum<span class="w"> </span>install<span class="w"> </span>git</span>
</pre></div></div><p>相应地，你必须有 <code class="docutils literal notranslate"><span class="pre">github</span></code> 帐户。
如果你还没有，去 <a class="reference external" href="https://github.com">github.com</a> 注册一个，
然后按照<a class="reference external" href="https://help.github.com/linux-set-up-git">设置 Git</a> 指引配置 git 。</p>
</section>
<section id="ssh">
<h2>添加 SSH 密钥（可选）<a class="headerlink" href="#ssh" title="Permalink to this heading"></a></h2>
<p>如果你计划向 Ceph 贡献代码、或者想通过 SSH 克隆（ <code class="docutils literal notranslate"><span class="pre">git&#64;github.com:ceph/ceph.git</span></code> ），你必须生成一个 SSH 密钥对。</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>如果你只是想克隆，不需要 SSH 密钥也可用
<code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">--recursive</span> <span class="pre">https://github.com/ceph/ceph.git</span></code> 克隆。</p>
</div>
<p>执行如下命令生成 SSH 密钥对用于 <code class="docutils literal notranslate"><span class="pre">github</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ssh-keygen</span>
</pre></div></div><p>打印出刚才生成的密钥，准备添加到你的 <code class="docutils literal notranslate"><span class="pre">github</span></code> 帐户，
用 <code class="docutils literal notranslate"><span class="pre">cat</span></code> 命令。（本例假设你用的是默认的文件路径）：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">cat<span class="w"> </span>.ssh/id_rsa.pub</span>
</pre></div></div><p>复制公钥。</p>
<p>进入 <code class="docutils literal notranslate"><span class="pre">github</span></code> 帐户，点击 “Account Settings”
（即 “tools” 图标），然后点击左侧导航条的 “SSH Keys” 。</p>
<p>点击 “SSH Keys” 列表里的 “Add SSH key” ，给密钥起个名字，
把复制的公钥粘帖进去，最后点击 “Add key” 按钮。</p>
</section>
<section id="id2">
<h2>克隆源码<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>执行下列命令克隆源码库：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">git<span class="w"> </span>clone<span class="w"> </span>--recursive<span class="w"> </span>https://github.com/ceph/ceph.git</span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span></code> 完成后，你应该已经得到了一份完整的 Ceph 源码库。</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>确保你获取到的源码库之内的各子模块都是最新的，
运行 <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">status</span></code> ，它会告诉你子模块是否过时了。
详情见 <a class="reference internal" href="#update-submodules"><span class="std std-ref">更新子模块</span></a> 。</p>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1"><span class="nb">cd</span><span class="w"> </span>ceph</span>
<span class="prompt1">git<span class="w"> </span>status</span>
</pre></div></div><section id="update-submodules">
<span id="id3"></span><h3>更新子模块<a class="headerlink" href="#update-submodules" title="Permalink to this heading"></a></h3>
<p>如果你的子模块（ submodule ）过时了，运行：</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">git<span class="w"> </span>submodule<span class="w"> </span>update<span class="w"> </span>--force<span class="w"> </span>--init<span class="w"> </span>--recursive<span class="w"> </span>--progress</span>
<span class="prompt1">git<span class="w"> </span>clean<span class="w"> </span>-fdx</span>
<span class="prompt1">git<span class="w"> </span>submodule<span class="w"> </span>foreach<span class="w"> </span>git<span class="w"> </span>clean<span class="w"> </span>-fdx</span>
</pre></div></div></div></blockquote>
<p>如果你的子模块目录仍然有问题，用
<code class="docutils literal notranslate"><span class="pre">rm</span> <span class="pre">-rf</span> <span class="pre">[directory</span> <span class="pre">name]</span></code> 删掉那个目录。然后再次运行
<code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">submodule</span> <span class="pre">update</span> <span class="pre">--init</span> <span class="pre">--recursive</span> <span class="pre">--progress</span></code> 。</p>
</section>
</section>
<section id="id4">
<h2>选择分支<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>克隆完源码和子模块后，你的源码库将默认位于 <code class="docutils literal notranslate"><span class="pre">main</span></code> 分支上，
这是个不稳定开发分支，你也可以切换到其他分支上。</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">main</span></code>: 不稳定开发分支；</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">stable-release-name</span></code>: 稳定的、 <a class="reference external" href="https://docs.ceph.com/en/latest/releases/#active-releases">活跃版本</a> 的名字，比如 <code class="docutils literal notranslate"><span class="pre">Pacific</span></code> ；</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">next</span></code>: 发布候选分支。</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">checkout</span> <span class="n">main</span>
</pre></div>
</div>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../get-tarballs/" class="btn btn-neutral float-left" title="下载 Ceph 源码包" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../build-ceph/" class="btn btn-neutral float-right" title="构建 Ceph" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>